/*
MICKEY-v2-bitslice - Bitslice implementation of MICKEY 2.0
Copyright (C) 2010 Deian Stefan

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MICKEY_BITSLICE_H__
#define __MICKEY_BITSLICE_H__
#include <stdint.h>

/* uword is the machine-depended word size */
typedef unsigned long uword;

#define  MICKEY_NR_STREAMS (sizeof(uword)*8)

typedef struct {
   /* Registers R and S are both 100-bit long */
   uword R[100]; int R0_pos;
   uword S[100];

   /* The key is 80-bits. Similary, the IV is up to 80-bits.*/
   uword keys[80]; int key_set;
   uword IVs[80];  int IV_set; int IVlen;

} mickey_state;

void mickey_init(mickey_state *ctx);
int mickey_load_key(mickey_state *ctx, const uint8_t key[80]);
int mickey_load_IV(mickey_state *ctx, const uint8_t *iv, uint32_t ivlen);
void mickey_setup(mickey_state *ctx);
void clock_kg(mickey_state *ctx, uword mixing, uword input_bits);
uword mickey_keystream(mickey_state *ctx);
void mickey_keystream_byte(mickey_state *ctx, uint8_t *keystream);


#endif
